﻿using System;
using Castle.ActiveRecord;

using Pampa.CRUD.Core;

namespace Demo.Model
{
    [ActiveRecord]
    public class Country : AbstractActiveRecord<Country>, IIdDescription
    {
        private int id;
        private string description;

        public Country()
        { 
        }

        [PrimaryKey]
        public virtual int ID
        {
            get { return id;}
            set { id = value;}
        }

        [Property]
        public virtual string Description
        {
            get { return description; }
            set { description = value; }
        }


        #region Miembros de IIdDescription

        string Pampa.CRUD.Core.IIdDescription.Id
        {
            get { return this.ID.ToString(); }
        }

        string Pampa.CRUD.Core.IIdDescription.Description
        {
            get { return this.Description; }
        }

        #endregion

        /// <summary>
        /// Este metodo hace falta si el Id devuelto por los combos debe parsearse para obtener un objeto id
        /// </summary>
        public static object ParseId(string id)
        {
            return Int32.Parse(id);
        }
    }
}
